home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 3495 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.4 KB  |  41 lines

  1. Path: solon.com!not-for-mail
  2. From: seebs@solutions.solon.com (Peter Seebach)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Basic Question on SWITCH
  5. Date: 29 Jan 1996 08:46:26 -0600
  6. Organization: Usenet Fact Police (Undercover)
  7. Message-ID: <4eimk2$eet@solutions.solon.com>
  8. References: <4e4cu4$95f@vixen.cso.uiuc.edu> <4eikud$e7b@solutions.solon.com>
  9. NNTP-Posting-Host: solutions.solon.com
  10.  
  11. In article <4eikud$e7b@solutions.solon.com>,
  12. Peter Seebach <seebs@solutions.solon.com> wrote:
  13. >main() {
  14. >    int c, x, printf();
  15. >    c = getchar();
  16. >    switch (x = ((c = (unsigned char) c), /* try to ensure a legal char. */
  17. >        ((!!isdigit(c)) << 1) | ((!!isalpha(c)) << 0)))
  18. >    default:
  19. >        printf(
  20. >    (x == 0 ? "'\\x%x' is neither a letter nor a number.\n" :
  21. >     (x == 1 ? "'%c' is a letter.\n" : (x == 2 ? "'%c' is a number.\n" :
  22. >      (x == 3 ? "'%c' is both a letter and a number.\n" :
  23. >        "'\\x%x' is odd.\n"))), c);
  24. Should be
  25.            "'\\x%x' is odd.\n")))), c);
  26. of course.
  27.  
  28. >As far as I can tell, this is legal and strictly conforming ANSI.
  29.  
  30. Okay, I mean, *apart* from the typo.
  31.  
  32. (Pretty good, though; in the entire life cycle of the program, it has had
  33. no bugs but typos that prevented compiles.)
  34.  
  35. -s
  36. -- 
  37. Peter Seebach - seebs@solon.com - Copyright 1995 Peter Seebach.
  38. C/Unix wizard -- C/Unix questions? Send mail for help.  No, really!
  39. Using trn?  Weird new newsgroup problem?  I know the fix!  Email me!
  40. The *other* C FAQ - ftp taniemarie.solon.com /pub/c/afq - Not A Flying Toy
  41.